package com.fankui.serviceedu.controller;

import com.fankui.commonutils.R;
import com.fankui.serviceedu.entity.subject.OneSubject;
import com.fankui.serviceedu.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author 范奎
 * @since 2023-11-23
 */
@Api(description = "课程分类")
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    @ApiOperation(value = "导入课程分类")
    @PostMapping("addSubject")
    public R addSubject(@ApiParam(name = "file", value = "文件上传对象") MultipartFile file) {
        subjectService.saveSubject(file, subjectService);
        return R.ok();
    }

    @ApiOperation(value = "课程分类列表")
    @GetMapping("getAllSubject")
    public R getAllSubject() {
        List<OneSubject> list = subjectService.getAllSubject();
        return R.ok().data("list", list);
    }
}

